import os
import json

# data_root = "/share/home/wuqingyao_danglingwei/datas/TACO_Data_20250314/full_20k_plus"
# out_meta_file = "/share/home/wuqingyao_danglingwei/datas/TACO_Data_20250314/data_for_animateanyone/base_2500_train.json"

data_root = "/WORK/PUBLIC/liuyebin_work/lingweidang/datas/TACO_Data_20250314/full_20k_plus"
out_meta_file = "/WORK/PUBLIC/liuyebin_work/lingweidang/datas/TACO_Data_20250314/data_for_animateanyone/base_2500_train.json"
os.makedirs(os.path.dirname(out_meta_file), exist_ok=True)

color_video_column_path = "base_2500_train_color_videos.txt"
pose_video_column_path = "base_2500_train_black_pose_videos.txt"

with open(os.path.join(data_root, color_video_column_path), "r") as f:
    color_video_column = f.readlines()

color_video_column = [line.strip() for line in color_video_column]

with open(os.path.join(data_root, pose_video_column_path), "r") as f:
    pose_video_column = f.readlines()

pose_video_column = [line.strip() for line in pose_video_column]

meta_infos = []
assert len(color_video_column) == len(pose_video_column)

for idx, (color_video_path, pose_video_path) in enumerate(zip(color_video_column, pose_video_column)):
    print(f"idx: {idx}")
    meta_infos.append({"video_path": os.path.join(data_root, color_video_path), "kps_path": os.path.join(data_root, pose_video_path)})
    assert os.path.exists(os.path.join(data_root, color_video_path)) and os.path.exists(os.path.join(data_root, pose_video_path))

with open(out_meta_file, "w") as f:
    json.dump(meta_infos, f, indent=4)

print(f"Done!")